package it.fuesi.expired.adapters;

import android.app.Fragment;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import it.fuesi.expired.R;
import it.fuesi.expired.api.client.TagsBroker;
import it.fuesi.expired.model.Tag;
import it.fuesi.expired.model.collections.TagCollection;

/**
 * Created by pascotto on 22/08/14.
 */
public class TagsAdapter extends AbstractAdapter<Tag,TagCollection> {


    public TagsAdapter(LayoutInflater inflater, TagCollection data, Context context, Fragment fragment)  {
        super(inflater, data, context, fragment);
    }

    @Override
    protected void drawView(View view, Tag item) {
         TextView name = (TextView)view.findViewById(R.id.item_name); // titlee

         name.setText(item.getName()); //FIXME
    }

    @Override
    protected boolean matchCurrentFilter(Tag obj, CharSequence searchText) {
        return searchText == null || obj.getName().toUpperCase().contains(searchText.toString().toUpperCase());
    }

    @Override
    protected int getListItemLayout(){
        return R.layout.tag;
    }

    @Override
    protected TagsBroker getClientBroker() {
        return new TagsBroker(API_ENDPOINT);
    }



}
